<!-- 商品页面 -->
<template>
	<view class="content">
		<!-- 列表 -->
		<view class="contents">
			<!-- 表格布局 -->
			<view class="bgbj">
				<view :class="listType == 0 ?'bgbjitem':'bgbjitem-heng'" v-for="(item,index) in scoreList "
				 @click="$Router.push({ path: '/pages/product/product-xq', query: { id: item.id, type: 'score' } })"
				 :key="index">
					<view class="bgbjitemimg">
						<image :src="item.image" mode="aspectFit"></image>
					</view>
					<view class="bgbjitem-xian"></view>
					<view class="bgbjitem-bottom">
						<view class="bgbjitem-title u-line-2">{{item.title}}</view>
						<view class="bgbjitem-des u-line-1">{{item.subtitle}}</view>
						<view class="bgbjitem-price">
							{{item.price}}
						</view>
						<view class="bgbjitem-buy">兑换</view>
					</view>
					
				</view>
			</view>
			<!-- 缺省页 -->
			<shopro-empty
				v-if="isEmpty"
				@click="$Router.pushTab('/pages/index/index')"
				:image="IMG_URL + '/imgs/empty/empty_goods.png'"
				tipText="暂无积分商品"
				btnText="去首页逛逛"
			>
			
			</shopro-empty>
			<!-- 加载更多 -->
			
			<u-loadmore v-if="!isEmpty" height="80rpx" :status="loadStatus" icon-type="flower" color="#ccc" />
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				listType:0,
				scoreList: [],
				isEmpty: false, //无数据
				loadStatus: 'loadmore', //loadmore-加载前的状态，loading-加载中的状态，nomore-没有更多的状态
				currentPage: 1,
				lastPage: 1,
				IMG_URL:this.$IMG_URL
			}
		},
		onShow() {
			
		},
		onHide() {
			
		},
		// 触底加载更多
		onReachBottom() {
			if (this.listParams.page < this.lastPage) {
				this.listParams.page += 1;
				this.getGoodsList();
			}
		},
		//点击刷新当前页面
		onTabItemTap : function(e) {
			// this.getsp(0)
		},
		onLoad() {
			this.getScoreShopsList();
			// 触底监听
			uni.$on('uOnReachBottom', () => {
				if (this.currentPage < this.lastPage) {
					this.currentPage += 1;
					this.getScoreShopsList();
				}
			});
		},
		methods: {
			//积分商品列表
			getScoreShopsList() {
				let that = this;
				that.loadStatus = 'loading';
				that.$http('goods.scoreList', {
					page: that.currentPage
				}).then(res => {
					if (res.code == 1) {
						that.scoreList = [...that.scoreList, ...res.data.data];
						that.isEmpty = !that.scoreList.length;
						that.lastPage = res.data.last_page;
						that.loadStatus = that.currentPage < res.data.last_page ? 'loadmore' : 'nomore';
					}
				});
			}
		}
	}
</script>

<style scoped lang="less">
	input{
		font-size: 26rpx;
		font-weight: 400;
		color: #4C4A4A;
	}
	.contents {
		padding-top: 10rpx;
	}
	.sskx{
		padding: 20rpx 0;
	}
	.content{
		background-color: #F6F6F6;
	}
	.ssk{
		width: 600rpx;
		height: 60rpx;
		background: #FFFFFF;
		border: 1rpx solid #D6D7DC;
		border-radius: 30rpx;
		margin: 0 auto ;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}
	.ssk>view{
		width: 100rpx;
		height: 100%;
		background: #FF9A33;
		border: 1rpx solid #D6D7DC;
		border-radius: 0rpx 30rpx 30rpx 0rpx;
	}
	.ssk>view /deep/ text{
		margin: 0 auto;
	}
	.ssk>input{
		width:calc(80% - 40rpx);
		padding: 0 20rpx;
		border: none;
		outline: none;
		height: 100%;
	}
	.spsx{
		background: #FFFFFF;
		border-radius: 10rpx 10rpx 0rpx 0rpx;
		display: flex;
		justify-content: space-around;
		align-items: center;
		padding: 30rpx 0;
	}
	.spsx>view{
		display: flex;
		align-items: center;
		font-size: 30rpx;
		font-weight: 500;
		color: #333333;
	}
	.c100>view{
		margin-right: 4rpx;
	}
	.bgbj{
		display: flex;
		justify-content: space-between;
		flex-wrap: wrap;
	}
	.bgbjitem{
		width: 340rpx;
		background: #FFFFFF;
		border-radius: 10rpx;
		margin-bottom: 20rpx;
	}
	.bgbjitemimg{
		text-align: center;
	}
	.bgbjitem{
		position:relative;
		.bgbjitemimg{
			width: 100%;
			height: 270rpx;
			image{
				width: 100%;
				height: 100%;
			}
		}
		.bgbjitem-xian{
			width: 80%;
			height: 2px;
			background: linear-gradient(90deg, #FFFFFF, #F28101, #FFFFFF);
			border-radius: 1px;
			margin: 0 auto;
			margin-top: 10rpx;
		}
		.bgbjitem-bottom{
			padding: 30rpx 20rpx;
			// padding-bottom: 30rpx;
			box-sizing: border-box;
			.bgbjitem-title{
				font-size: 28rpx;
				font-weight: bold;
				margin-bottom: 19rpx;
			}
			.bgbjitem-des{
				color: #7C7C7C;
				font-size: 24rpx;
				margin-bottom: 20rpx;
			}
			.bgbjitem-price{
				font-size: 36rpx;
				color: #FF9A33;
				font-weight: 800;
				text{
					font-size: 24rpx;
				}
			}
			
		}
	}
	.bgbjitem-buy{
		width: 90rpx;
		height: 44rpx;
		border: 1px solid #FF9A33;
		border-radius: 30rpx 0px 10rpx 0px;
		display: flex;
		align-items: center;
		justify-content: center;
		font-size: 26rpx;
		color: #FF9A33;
		position: absolute;
		right: 0;
		bottom: 0;
	}
	.bgbjitem-heng{
		width: 100%;
		display: flex;
		align-items: center;
		background: #FFFFFF;
		margin-bottom: 20rpx;
		position: relative;
		.bgbjitemimg{
			width: 250rpx;
			height: 245rpx;
			image{
				width: 100%;
				height: 100%;
			}
		}
		.bgbjitem-xian{
			width: 2rpx;
			height: 237rpx;
			background: linear-gradient(0deg, #FFFFFF, #F28101, #FFFFFF);
			border-radius: 1px;
			margin-right: 49rpx;
			margin-left: 10rpx;
		}
		.bgbjitem-title{
			font-size: 28rpx;
			font-weight: bold;
			margin-bottom: 19rpx;
		}
		.bgbjitem-des{
			font-size: 24rpx;
			color: #7C7C7C;
			margin-bottom: 20rpx;
		}
		.bgbjitem-price{
			font-size: 36rpx;
			color: #FF9A33;
			font-weight: 800;
			text{
				font-size: 24rpx;
			}
		}
	}
	.bgbjitem-heng>view:last-of-type{
		width: 370rpx;
	}
	
	.empty-text{
		margin-bottom: 40rpx !important;
	}
</style>
